package com.galaxy.nebula.account.dao.impl;

import java.sql.SQLException;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.galaxy.nebula.account.dao.IAccountDAO;
import com.galaxy.nebula.account.model.Account;

public class AccountDAOImpl extends SqlMapClientDaoSupport implements IAccountDAO {

    @Override
    public Long accountSeq() throws SQLException {
        return (Long) this.getSqlMapClient().queryForObject("accountSeq");
    }
    
    @Override
    public Account findAccountById(Long id) throws SQLException {
        if (id == null) {
            return null;
        }
        return (Account) this.getSqlMapClient().queryForObject("findAccountById", id);
    }
    
    @Override
    public Account insertAccount(Account account) throws SQLException {
        if (account == null) {
            return null;
        }
        return (Account) this.getSqlMapClient().insert("insertAccount", account);
    }

    @Override
    public int updateAccount(Account account) throws SQLException {
        if (account == null || account.getId() == null) {
            return -1;
        }
        return this.getSqlMapClient().update("updateAccount", account);
    }

}
